﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Text;
using OgilvyOne.BLL;
using OgilvyOne.Model;

using OgilvyOne.UKNow.BLL;
using OgilvyOne.UKNow.Model;
using System.Collections.Generic;
using ECCIT;

public partial class admin_UKNOW_impression_impression_list : AdminBasePage
{
    private const string VIEWSTATE_LAYER_ID = "layerid";
    private const string VIEWSTATE_COLUMN_ID = "columnid";
    private const string VIEWSTATE_PAGE_NO = "pageNum";//
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            ViewState[VIEWSTATE_LAYER_ID] = Request.Params[VIEWSTATE_LAYER_ID];
            ViewState[VIEWSTATE_COLUMN_ID] = Request.Params[VIEWSTATE_COLUMN_ID];

            this.headers.Text = new ColumnBll().LayeridColumnConNaiv(Request.Params[""]);
            ViewState[VIEWSTATE_PAGE_NO] = "1";//
            Grid_viewBild();
        }
        else
        {
            if (string.IsNullOrEmpty(ViewState[VIEWSTATE_PAGE_NO].ToString())) return;
            string sPageNum = Request.Params[VIEWSTATE_PAGE_NO];
            if (ViewState[VIEWSTATE_PAGE_NO].ToString() != sPageNum)
            {
                ViewState[VIEWSTATE_PAGE_NO] = sPageNum;
                Grid_viewBild();
            }
        }
    }
    private string ReturnQueryString(bool b)
    {
        string url = string.Format("{0}{1}={2}&{3}={4}&{5}={6}", (b ? "?" : ""),
            VIEWSTATE_LAYER_ID, ViewState[VIEWSTATE_LAYER_ID],
            VIEWSTATE_COLUMN_ID, ViewState[VIEWSTATE_COLUMN_ID],
            "langID", this.LangID
            );
        return url;
    }
    private void Grid_viewBild()
    {
        int columnid = int.Parse(Request.Params["columnid"]);
        ColumnModel cm = new ColumnBll().GetColumn(columnid);
        IList<VotesKeyWordsModel> votekwsls = new VotesKeyWordsBLL(LangID).selectKeyWords();
        GridView1.DataSource = votekwsls;
        //GridView1.PageSize = 10;
        GridView1.PageIndex = int.Parse(ViewState[VIEWSTATE_PAGE_NO].ToString()) - 1;//
        GridView1.DataBind();
        this.pagehtml.Text = getPageHtml(GridView1.PageCount, GridView1.PageIndex + 1, votekwsls.Count);
    }
    protected void Add_click(object sender, EventArgs e)
    {
        Response.Redirect(string.Format("impression_add.aspx{0}", ReturnQueryString(true)), true);
    }
    protected void Del_click(object sender, EventArgs e)
    {
        int eid = int.Parse(((LinkButton)sender).CommandArgument);
        ResultInfo res = new VotesKeyWordsBLL(LangID).delKeyWords(eid);
        if (res.Result)
        {
            Response.Write("<script>alert('" + res.Message + "')</script>");
        }
        else
        {
            Response.Write(res.Message);
        }
        Grid_viewBild();
    }
    protected void Set_click(object sender, EventArgs e)
    {
        //修改单个关键字的发布状态
        int eid = int.Parse(((LinkButton)sender).CommandArgument);
        new VotesKeyWordsBLL(LangID).modPubOne(eid);
        Grid_viewBild();
    }
    protected void Mod_click(object sender, EventArgs e)
    {
        Response.Redirect("impression_add.aspx" + ReturnQueryString(true) + "&kid=" + ((LinkButton)sender).CommandArgument, true);
    }
}